package com.lovo.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.lovo.bean.Tenderinfo;
import com.lovo.service.ITenderinfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author lovo
 * @since 2022-09-17
 */
@RestController
@RequestMapping("supplier/tenderinfo")
public class TenderinfoController {


    @Autowired
    ITenderinfoService tenderinfoService;

    @GetMapping("findTenderInfoBySupId/{pageNO}/{supId}")
    public IPage<Tenderinfo> findTenderInfoBySupId(@PathVariable("pageNO") Integer pageNO,
                                                   @PathVariable("supId") Integer supId) {
        return tenderinfoService.findAllTenderInfoBySupId(pageNO, supId);
    }

    @GetMapping("findTenderInfoById/{id}")
    public Tenderinfo findTenderInfoById(@PathVariable("id") Integer id) {
        return tenderinfoService.findTenderInfoById(id);
    }

    @GetMapping("sendTenderInfo/{supplierId}/{price}/{tenderId}/{info}/{productId}")
    public String sendTenderInfo(@PathVariable("supplierId") Integer supplierId,
                                 @PathVariable("price") Integer price,
                                 @PathVariable("tenderId") Integer tenderId,
                                 @PathVariable("info") String info,
                                 @PathVariable("productId") Integer productId) {

        tenderinfoService.sendTendInfo(supplierId, price, tenderId, info, productId);
        return "ok";
    }


    @PutMapping("updateByTenderId/{tenderInfoId}")
    public String updateByTenderId(
            @PathVariable("tenderInfoId") Integer tenderInfoId) {
        boolean a = tenderinfoService.updateTenderInfoStatus(tenderInfoId);
        if (a) {
            return "ok";
        }
        return "no";
    }


}
